<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>技术合同审核</title>
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res}/js/projectapp/prjpublic.js"></script>
</head>
<body>
	<div class="soBox">
		<div class="detail ico_search">
		<div class="text">
			<table>
				<tr>
					<td>
						<cpt:search key="techctrorg_audit"  repeatColumn="3" displayCount="7" leftStyle="width:100px"></cpt:search>
					</td>
				</tr>
				<tr>
				<td>
					<div class="clear_h10"></div>
					<input type='button' id='searchBt' class="button_an" value='查询'/>
				</td>
				</tr>
			</table>
			</div>
		</div>
	</div>
	<div class="clear_h10"></div>
	<div>
		<div id='TopBarMnt'></div>
		<table id='dataGrid'></table>
		<div id='dataBar'></div>
	</div>
	<input type="hidden" id="checkedStatus" name="checkedStatus" value="" />
	<script type="text/javascript">
		$(document).ready(function() {
			buildGrid();
		});
		var irisGrid = new IrisGrid("dataGrid", "dataBar", 'TopBarMnt');
		var prcWin = new progressWin("${res}");//初始化遮罩层
		/** 表格初始化**/
		function buildGrid() {
			var columnAttrList = new Array();
			
			columnAttr = new ColumnAttr("合同名称", "zhTitle","zhTitle", 1, "left", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("业务类型", "grantName","grantName", 1, "left", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("买方名称", "buyerName","sellerTypeName", 1, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("卖方名称", "sellerName","sellerName", 1, "left", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("登记机构", "regName","regName", 1, "center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("负责人", "zhName","zhName", 1, "center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("申报单位", "orgName","orgName", 1, "left", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("状态", "statusName","statusName", 1, "left", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("申报年度", "statYear", "statYear", 1,"center", true);
			columnAttrList.push(columnAttr);
						
			columnAttr = new ColumnAttr("审核意见", "comment", "comment", 1,"center", false);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("PDF", "pdf", "pdf",1,"center", false);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("操作", "", "", 2,"center", false);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("status", "status", "status", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("subGrantCode", "subGrantCode", "subGrantCode", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("posCode", "posCode", "posCode", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			
			irisGrid.setColumnAttrs(columnAttrList);
			
			var flag="${flag}";
			var is_slorsh="";
			var btn_name="";
			if(flag=="1"){
				is_slorsh="sl";
				btn_name="接收纸质材料";
			}else{
				is_slorsh="sh";
			}
			if(is_slorsh=="sl"){
				irisGrid.setToolsBar([
      				{//工具栏建按钮
      					id : 'approve',//按钮ID
      					name : btn_name,//按钮名称
      					trigger : function(gridObj, selectIdArray, recordRows) {//按钮onclick方法 grid本身 选中的行id 总行数
      						var checkflag = true;
      						var prpCodes = getSelOpt();
      						prpCodes = prpCodes + "";
      						var ps = prpCodes.split(",");
      			
      						if(selectIdArray.length==0) {
      							scmError("请先选择要操作的技术合同");
      							return;
      						}
      						var status = "";
      						if (selectIdArray.length > 0) {
      						for ( var i = 0; i < ps.length; i++) {
      							status = status +$.trim($("#status_"+ps[i]).html())+",";
      						}
      						status = status.substring(0,status.length-1);
      						if (checkflag) {
      							var num = ps.length;
      							if (confirm("是否确认受理这" + num + "份技术合同?")) {
      								$("#checkedStatus").val(status);
      								prpApprove(prpCodes,44);
      							}
      						}
      			
      					}
      					}
      				},
      				{//工具栏建按钮
      						id : 'return',//按钮ID
      						name : "退回修改",//按钮名称
      						trigger : function(gridObj, selectIdArray, recordRows) {//按钮onclick方法 grid本身 选中的行id 总行数
      							var checkflag = true;
      							var prpCodes = getSelOpt();
      							prpCodes = prpCodes + "";
      							var ps = prpCodes.split(",");
      			
      							if(selectIdArray.length==0) {
      								scmError("请先选择要操作的技术合同");
      								return;
      							}
      							var status = "";
      							if (selectIdArray.length > 0) {
      							for ( var i = 0; i < ps.length; i++) {
      								status = status +$.trim($("#status_"+ps[i]).html())+",";
      							}
      							
      							if (checkflag) {
      								var num = ps.length;
      								if (confirm("是否确认退回修改这" + num + "份技术合同?")) {
      									$("#checkedStatus").val(status);
      									prpReturn(prpCodes);
      								}
      							}
      			
      						}
      					}
      				}
      			  ]);
			}
			if(is_slorsh=="sh"){
				irisGrid.setToolsBar([	
	     				{//工具栏建按钮
	     						id : 'return',//按钮ID
	     						name : "退回修改",//按钮名称
	     						trigger : function(gridObj, selectIdArray, recordRows) {//按钮onclick方法 grid本身 选中的行id 总行数
	     							var checkflag = true;
	     							var prpCodes = getSelOpt();
	     							prpCodes = prpCodes + "";
	     							var ps = prpCodes.split(",");
	     			
	     							if(selectIdArray.length==0) {
	     								scmError("请先选择要操作的技术合同");
	     								return;
	     							}
	     							var status = "";
	     							if (selectIdArray.length > 0) {
	     							for ( var i = 0; i < ps.length; i++) {
	     								status = status +$.trim($("#status_"+ps[i]).html())+",";
	     							}
	     							
	     							if (checkflag) {
	     								var num = ps.length;
	     								if (confirm("是否确认退回修改这" + num + "份技术合同?")) {
	     									$("#checkedStatus").val(status);
	     									prpReturn(prpCodes);
	     								}
	     							}
	     			
	     						}
	     					}
	     				}
     			  ]);
			}
			irisGrid.setUrl("${ctx}/prpapprove/techctrorg_audit?is_slorsh="+is_slorsh);//查询url
			irisGrid.setCaption("暂写");
			irisGrid.setDefaultSortName("status,NLSSORT(zhTitle,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(grantName,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(sellerName,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(buyerName,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(zhName,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(statYear,'NLS_SORT = SCHINESE_PINYIN_M'),posCode");//默认排序字段
			irisGrid.setDefaultSortorder("asc");
			irisGrid.setWidth(978);//整个表格宽度
			irisGrid.setCheckAble(true);//表格左边是否要复选框
			irisGrid.setShowRowIndex(true);//是否显示行号
			irisGrid.setQueryBox('searchBt', 'techctrorg_audit');//后面的参数是“项目验收情况”跳转过来带的参数
			irisGrid.build();
		}
		
		var getSelOpt = function() {
			var g = "";
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				if (obj.checked) {
					g += "," + obj.id.replace("jqg_dataGrid_", "");
				}
			});
			if (g != "") {
				g = g.substring(1);
			}
			return $.trim(g);
		};
				
		function refreshGrid(){
			irisGrid.getGridDom().jqGrid("refresh",0);
		}
		
		function prpApprove(prpCode,grantCode){
			var url = "${ctx}/prpapprove/prp-pass?prpCodes="+prpCode+"&grantCode="+grantCode+"&TB_iframe=true&height=560&width=850";
			tb_show("审核通过意见（最多为500字）", url, false);
		}
		
		function prpReturn(prpCode){
			var url = "${ctx}/prpapprove/prp-return?prpCodes="+prpCode+"&TB_iframe=true&height=560&width=850";
			tb_show("退回修改意见（最多为500字）", url, false);
		}
		
		function modifyTechCtrDialog(posCode,prpCode){
			var status = $("#status_"+prpCode).text();
			var url="${ctx}/prpapprove/modifyTechCtrDialog?posCode="+posCode+"&status="+status+"&TB_iframe=true&height=560&width=850";
			tb_show("修改技术合同登记申请信息", url, false);
		}
		
		function prpNotPass(prpCode){
			var url = "${ctx}/prpapprove/prp-not-pass?prpCodes="+prpCode+"&is_jsht=1&TB_iframe=true&height=560&width=850";
			tb_show("批复不同意意见（最多为500字）", url, false);
		}
		
		function prpApprovedialog(prpCode,grantCode){
			var selectid= prpCode;
			var curDate = "${curDate}";
			var roleId = 14;
			var posCode = $("#posCode_"+selectid).val();
			var subGrantCode = $("#subGrantCode_"+selectid).val();
			var status = $("#status_"+selectid).text();
			var dialogUrl = "${ctx}/prpapprove/openprpapprovedialog?category=A&roleId="+roleId+"&status="+status+"&curDate="+curDate+"&prpCodes="+prpCode+"&posCode="+posCode+"&grantCode="+grantCode+"&subGrantCode="+subGrantCode+"&TB_iframe=true&height=250&width=410";
		   window.open(dialogUrl,'newwin');
		}
		function viewComment(des3Prpcode){
			var url="${ctx}/proposal/view/audit-comment-view?posCode="+des3Prpcode+"&TB_iframe=true&height=390&width=720";
			tb_show("审核意见", url, false);
		}
		
		function search(){
			$("#searchBt").click();
		}
	</script>
</body>
</html>